import { typeStock } from "./inStock";
import { createAlpha } from "./alpha";
import { createInnovationZone } from "./innovationZone";
import { createPerpetualContract } from './perpetualContract'
import { createDelivery } from './delivery'
// import { observeTransactionDetails } from "./watch/transactionTable/transactionTable.js";
import { observeTransactionDetails } from "@/content-scripts/watch/transactionTable/transactionTable";

import { sportOrederTopSearch, sportOrederHistoryTopSearch, sportOrederRecordTopSearch } from "@/content-scripts/watch/order/sportOreder"
// import { createorder } from "@/content-scripts/components/order";
// import { creatrecordeorder } from "@/content-scripts/components/order/record";
// import { createhistoryorder } from "@/content-scripts/components/order/history";
export function createTradingAction() {
  const currentUrl = window.location.href;
  console.log(currentUrl, 'currentUrl is not defined6');
  console.log("当前页面的 URL:", currentUrl);
  console.log(currentUrl.includes('https://www.gate.io/zh/futures') && !currentUrl.includes('https://www.gate.io/zh/futures-'), "currentUrl.includes('https://www.gate.io/zh/futures') && !currentUrl.includes('https://www.gate.io/zh/futures-')");
  if (currentUrl) {
    if (currentUrl.includes('https://www.gate.com/zh/trade') || currentUrl.includes('https://www.gate.com/trade')) {
      typeStock();
      observeTransactionDetails();
    }
    if (currentUrl.includes('https://www.gate.com/zh/alpha')) {
      createAlpha()
    }
    if (currentUrl.includes('https://www.gate.com/zh/pilot')) {
      createInnovationZone()
    }
    if ((currentUrl.includes('https://www.gate.com/zh/futures') || currentUrl.includes('https://www.gate.com/futures')) && !currentUrl.includes('https://www.gate.com/zh/futures-') && !currentUrl.includes('https://www.gate.com/futures-')) {
      console.log('www.gate.com/zh/futures');
      localStorage.setItem('pagePagination', JSON.stringify({
        "current": 1,
        "pageSize": 10,
        isChange: true
      }))
      setTimeout(() => {
        createPerpetualContract()
      }, 3000)

    }
    if (currentUrl.includes('https://www.gate.com/zh/futures-delivery')) {
      createDelivery()
    }
    if (currentUrl.includes('https://www.gate.com/zh/myaccount/order/spot') && !currentUrl.includes('history') && !currentUrl.includes('record')) {
      sportOrederTopSearch()
      // createorder()
    }
    if (currentUrl.includes('https://www.gate.com/zh/myaccount/order/spot/history')) {
      // createhistoryorder()
      sportOrederHistoryTopSearch()
    }
    if (currentUrl.includes('https://www.gate.com/zh/myaccount/order/spot/record')) {
      // creatrecordeorder()
      sportOrederRecordTopSearch()
    }
  }

}
